import store from "@/store/store";
import axios from "@/utils/request";
import qs from "qs";

//获取评论
const getComents = (params) => {
  const token = store.state.token;
  let headers = {};
  if (token !== "") {
    headers = {
      headers: {
        Authorization: "Bearer " + store.state.token,
      },
    };
  }
  return axios.get("/public/comments?" + qs.stringify(params), headers);
};

//添加评论
const addComment = (editinfo) => axios.post("/comments/addcomments", editinfo);

//更新
const updataComment = (data) => axios.post("/comments/updata", data);

//采纳
const addBest = (params) =>
  axios.get("/comments/setbest?" + qs.stringify(params));

//点赞
const setHands = (handinfo) => {
  return axios.get("/comments/hands?" + qs.stringify(handinfo));
};

export { getComents, addComment, updataComment, addBest, setHands };
